#ifndef SUBJECT_HPP_
#define SUBJECT_HPP_

#include "Abstract.hpp"

class WeatherData : public Subject
{
private:
  float _temperature;
  float _humidity;
  float _pressure;
  std::unordered_set<Observer *> _tableObserver;

public:
  WeatherData()
      : _temperature(0), _humidity(0), _pressure(0)
  {
  }

  float GetTemperature() const
  {
    return _temperature;
  }

  float GetHumidity() const
  {
    return _humidity;
  }

  float GetPressure() const
  {
    return _pressure;
  }

  void RegisterObserver(Observer *po)
  {
    if (po != nullptr)
      _tableObserver.insert(po);
  }

  void RemoveObserver(Observer *po)
  {
    if (po != nullptr && _tableObserver.find(po) != _tableObserver.end())
      _tableObserver.erase(po);
  }

  void NotifyObserver()
  {
    for (Observer *observer : _tableObserver)
      observer->Update();
  }

  void MeasureChanged()
  {
    NotifyObserver();
  }

  void SetMeasures(float temp, float humidity, float pressure)
  {
    _temperature = temp;
    _humidity = humidity;
    _pressure = pressure;
    MeasureChanged();
  }

  // void GetTemperature(){}
  // void GetHumidity() {}
  // void GetPressure() {}

  ~WeatherData() {}
};

#endif
